-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix vi-mode search feature to work similar to Vim #996
Conversation
…query is matched.
src/ext/isearch.lisp
Outdated
(unless (funcall *isearch-search-function* (current-point) *isearch-string*) | ||
(move-point (current-point) *isearch-start-point*)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed here because I think the current behavior is not intended that the cursor point doesn't go back when the search fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see.
if you write the following, the current-point might not be broken when interrupted.
(with-point ((point (current-point)))
(when (funcall *isearch-search-function* point *isearch-string*)
(move-point (current-point) point)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that looks better. I'll rewrite it as you suggested. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this has to be the code I originally changed.
For example, when I have a buffer like the following:
[a]pple orange grape
When starting ISearch with C-s lisp
, then the cursor moves to app[l]e
even though the search is failed.
It's better to go back to the starting point when the search has failed. How do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR #1002
(prog1 | ||
(cond ((variable-value 'isearch-next-last :buffer) | ||
(setf (variable-value 'isearch-next-last :buffer) nil) | ||
(with-point ((p (current-point))) | ||
(buffer-start p) | ||
(if (funcall *isearch-search-forward-function* p *isearch-string*) | ||
(progn | ||
(move-point (current-point) p) | ||
t) | ||
nil))) | ||
((not (funcall *isearch-search-forward-function* (current-point) *isearch-string*)) | ||
(setf (variable-value 'isearch-next-last :buffer) t) | ||
nil) | ||
(t)) | ||
(isearch-update-display)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to return a boolean value to tell whether the search is successful.
((not (funcall *isearch-search-backward-function* (current-point) *isearch-string*)) | ||
(setf (variable-value 'isearch-prev-last :buffer) t) | ||
nil) | ||
(t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns T. Is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I changed this to return a boolean value as I did to isearch-next
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I understand now 👍
It looks very good, Thanks! |
/
), moving to the next match (n
)n
andN
when searching backward (?
)n
should search backward if the last search was backwardfixes #314